<?php
namespace Index\Controller;
use Think\Controller;
class UController extends CommonController {
    public function index(){

        // if ($id=I('get.id' and $id=$_SESSION['id'])) {
        //     $id=$_SESSION['id'];
        // }elseif($id=$_SESSION['id']){
        //     $id=$_SESSION['id'];
        // }else{
        //     $id=I('get.id');
        // }
    	$id=I('get.id');

    	if (!$id) {
    		$id=$_SESSION['uid'];
    	}
        //取最近回答问题
        $sql="select t1.content,t1.create_time,t2.title from answer t1 inner join question t2 on t1.qid=t2.id  where t1.uid='$id'"; 

        $answer=M()->query($sql);
        $sql="select * from question where uid='$id'";
        $question=M()->query($sql);
        $this->assign('question',$question);
        $this->assign('answer',$answer);

    	$data=M('user')->find($id);
        // var_dump($data);
    	$this->assign('data',$data);
    	$this->assign('title',current($data)['nickname']."个人中心");
       $this->display();

    }
}
?>